<template>
	<div class="login f-bg">
		<div class="login-ct">
			<el-image :src="require('@/assets/images/gaq.png')" fit="fil" class="login-logo">
			</el-image>
			<div class="login-box">
				<div class="login-title">
					<el-image :src="require('@/assets/images/badges-2.png')" fit="fil" class="logo"></el-image>
					<div>图巴诺后台管理系统</div>
				</div>
				<el-form>
					<el-form-item>
						<el-input placeholder="账号" v-model="adminForm.username"></el-input>
					</el-form-item>
					<el-form-item>
						<el-input placeholder="密码" type="password" v-model="adminForm.password"
							@keyup.enter="submitForm"></el-input>
					</el-form-item>
					<el-form-item>
						<el-button @click="submitForm('adminForm')">登录</el-button>
					</el-form-item>
				</el-form>
			</div>
		</div>
	</div>
</template>

<script>
	import API from '@/api/login.js'

	export default {
		name: 'login',
		data() {
			return {
				adminForm: {
					username: 'ceshiadmin',
					password: '123456'
				},
			}
		},
		methods: {
			submitForm() {
				var self = this;
				API.login(self.adminForm).then(res => {
					localStorage.setItem('token', res.data.token);
					localStorage.setItem('username', self.adminForm.username);
					self.$router.push('/');
				}).catch(err => {
					self.$message.error(err.response.data.message)
				})
				// localStorage.setItem('username', 'admin')
				// self.$router.push('/');
			}
		}

	}
</script>

<style scoped lang="scss">
	.f-bg {
		background-color: #000066;
	}
</style>
